//#version 410

uniform sampler2DRect uWave;
uniform sampler2DRect uFiltConst;
uniform ivec2 uDir;

in vec2 vTexCoords;

out vec4 oResult;

void main()
{
    ivec2 iTexCoords=ivec2(vTexCoords);
    float wght=texelFetch(uFiltConst, iTexCoords).r;
    float otherWghts=0.5*(1-wght);

    oResult.r = otherWghts*(texelFetch(uWave, iTexCoords-uDir).r + texelFetch(uWave, iTexCoords+uDir).r) +
        wght*texelFetch(uWave, iTexCoords).r;
}